﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.MediaCenter;
using Microsoft.MediaCenter.Hosting;

namespace RMC.Commands
{
	internal class HelpCommand : ICommand
	{

		#region ICommand Members

		public string Syntax
		{
			get { return "help [command]"; }
		}

		public string Help
		{
			get { return @"help [command]

 - command = name of command to show full help
"; }
		}

		public CommandResult Execute(string args)
		{
			CommandResult cr = new CommandResult();
			cr.Type = CommandResultType.ExecutedWithContent;

			StringBuilder sb = new StringBuilder();
			sb.AppendLine("Help - Remote for Windows 7 Media Center");
			sb.AppendLine("------------------------------------------------------------");
			ICommand c;
			if (Command.list.TryGetValue(args.ToLower(), out c))
			{
				sb.AppendLine(c.Help);
			}
			else
			{
				foreach (ICommand cmd in Command.list.Values)
				{
					sb.AppendLine(cmd.Syntax);
				}
			}

			cr.Content = sb.ToString();

			return cr;
		}

		#endregion
	}
}
